package com.qax.scheduler.spring.boot.autoconfigure;

import com.qax.scheduler.spring.boot.autoconfigure.properties.JobSourceProperties;
import com.qax.task.timer.core.JobSourceReporter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author leiliang
 */
@Configuration
@ConditionalOnClass(JobSourceReporter.class)
@EnableConfigurationProperties(JobSourceProperties.class)
public class JobSourceReporterAutoConfigure {

    private static final Logger LOGGER = LoggerFactory.getLogger(JobSourceReporterAutoConfigure.class);

    @Bean(initMethod = "init")
    @ConditionalOnMissingBean
    public JobSourceReporter jobMinaSourceReporter() {
        LOGGER.info("Init JobMinaSourceReporter");
        return JobSourceReporterBuilder.build();
    }
}
